package camp.android.cookbook;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;


public class Recipe implements Serializable{
	private String title;
	private String subtitle;
	private List<Ingredient> ingredients;
	private List<String> procedure;
	private List<String> notes;
	
	public Recipe(String t, String st)
	{
		title = t;
		subtitle = st;
		ingredients = new ArrayList<Ingredient>();
		procedure = new ArrayList<String>();
		notes = new ArrayList<String>();
	}
	
	public void addIngredient(String ingredient, String quantity)
	{
		ingredients.add(new Ingredient(ingredient, quantity));
	}
	
	public void addStep(String p)
	{
		procedure.add(p);
	}
	
	public void  addNote(String n)
	{
		notes.add(n);
	}
	
	public String toString()
	{
		return title;
	}

	public String getTitle() {
		return title;
	}
	
	public String getSubtitle() {
		return subtitle;
	}
	
	public List<Ingredient> getIngredientsList()
	{
		return ingredients;
	}
	
	public String getIngredients() {
		String result = "";
		for (int i = 0; i < ingredients.size(); i++) {
			result+=(i+1) + ". " +ingredients.get(i).toString()+"\n";
		}
		return result;
	}
	
	public List<String> getProcedureList()
	{
		return procedure;
	}
	
	public String getProcedure() {
		String result = "";
		for (int i = 0; i < procedure.size(); i++) {
			result+=(i+1) + ". " + procedure.get(i)+"\n";
		}
		return result;
	}
	
	public void clearProcedure()
	{
		procedure.clear();
	}
	
	public List<String> getNotesList()
	{
		return notes;
	}
	
	public String getNotes() {
		String result = "";
		for (String n : notes) {
			result += n+"\n";
		}
		return result;
	}
	
	public void clearNotes()
	{
		notes.clear();
	}
	
	/**
	 * Identifying variable is the title (eventually modify to give each Recipe an ID?)
	 */
	public boolean equals(Object that)
	{
		Recipe thatRecipe = (Recipe)that;
		return thatRecipe.getTitle().equals(title);
	}
}